<?php

class User_Form_Register extends Engine_Form {
	
	public function __construct($options = null) {
		parent::__construct($options);
		
		$this->setAction('/user/register')
			 ->setMethod('post');
			 
		$username = $this->createElement('text', 'username');
		$username->addValidator('alnum')
				 ->addValidator('regex', false, array('/^[a-z]+/'))
				 ->addValidator('stringLength', false, array(4, 15))
				 ->setRequired(true)
				 ->addFilter('StringToLower')
				 ->setLabel($this->translate->_('ENGINE_REGISTER_FORM_USERNAME_LABEL'));
			 
		$firstname = $this->createElement('text', 'firstname');
		$firstname->addValidator('alnum')
				 ->addValidator('regex', false, array('/^[a-zA-Z]+/'))
				 ->addValidator('stringLength', false, array(5, 20))
				 ->setRequired(true)
				 ->setLabel($this->translate->_('ENGINE_REGISTER_FORM_FIRSTNAME_LABEL'));

		$lastname = $this->createElement('text', 'lastname');
		$lastname->addValidator('alnum')
				 ->addValidator('regex', false, array('/^[a-zA-Z]+/'))
				 ->addValidator('stringLength', false, array(5, 20))
				 ->setRequired(true)
				 ->setLabel($this->translate->_('ENGINE_REGISTER_FORM_LASTNAME_LABEL'));
	
		$password = $this->createElement('password', 'password');
		$password->addValidator('stringLength', false, array(6, 20))
				 ->setRequired(true)
				 ->setLabel($this->translate->_('ENGINE_REGISTER_FORM_PASSWORD_LABEL'));
				 
		$verify_password = $this->createElement('password', 'verify_password');
		$verify_password->addValidator('stringLength', false, array(6, 20))
				 		->setRequired(true)
				 		->setLabel($this->translate->_('ENGINE_REGISTER_FORM_VERIFY_PASSWORD_LABEL'));
				 
		$email = $this->createElement('text', 'useremail');
		$email->addValidator('emailAddress')
			  ->setRequired(true)
			  ->addFilter('StringToLower')
			  ->setLabel($this->translate->_('ENGINE_REGISTER_FORM_EMAIL_LABEL'));

		$verify_email = $this->createElement('text', 'verify_email');
		$verify_email->addValidator('emailAddress')
			  		->setRequired(true)
			  		->addFilter('StringToLower')
			  		->setLabel($this->translate->_('ENGINE_REGISTER_FORM_VERIFY_EMAIL_LABEL'));			  
			  
		$this->addElement($username)
			 ->addElement($firstname)
			 ->addElement($lastname)
			 ->addElement($password)
			 ->addElement($verify_password)
			 ->addElement($email)
			 ->addElement($verify_email)
			 ->addElement('submit', 'register', array('label' => $this->translate->_('ENGINE_WORD_REGISTER')));
		
	}
}

?>